package org.example.service;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Service;

@Service
public class ConsumerListener {
    @KafkaListener(topics = "test")
    public void listenGroup01(ConsumerRecord<String, String> record, Acknowledgment ack) {
        System.out.println("-----------------MyGroup start-------------------");
        String value = record.value();
        System.out.println(value);
        System.out.println(record);
        //手动提交offset
        ack.acknowledge();
        System.out.println("-----------------MyGroup end-------------------");
    }
}
